package yibao.youyun.com.yibao.Fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.zanlabs.widget.infiniteviewpager.InfiniteViewPager;
import com.zanlabs.widget.infiniteviewpager.indicator.CirclePageIndicator;

import yibao.youyun.com.yibao.Adapter.MockPagerAdapter;
import yibao.youyun.com.yibao.R;


public class PerfromResFragment extends Fragment
{

    private InfiniteViewPager mInfiniteViewpagr;
    private View view;
    private CirclePageIndicator indicator;
    public PerfromResFragment()
    {
        // Required empty public constructor
    }

    public static PerfromResFragment newInstance()
    {
        return new PerfromResFragment();
    }

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState)
    {

        return inflater.inflate(R.layout.fragment_perfrom_res, null, false);
    }
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState)
    {
        super.onViewCreated(view, savedInstanceState);
        this.view = view;
        initviewtoppager();
    }
    private void initviewtoppager()
    {
        mInfiniteViewpagr=(InfiniteViewPager)view.findViewById(R.id.perfrom_topviewpager);
        indicator = (CirclePageIndicator) view.findViewById(R.id.perfrom_indicator);
        MockPagerAdapter pagerAdapter = new MockPagerAdapter(getContext());
        mInfiniteViewpagr.setAdapter(pagerAdapter);
        mInfiniteViewpagr.setAutoScrollTime(2000);
        mInfiniteViewpagr.startAutoScroll();
        indicator.setViewPager(mInfiniteViewpagr);
        indicator.setCentered(false);

    }
    @Override
    public void onResume()
    {
        super.onResume();
        if (mInfiniteViewpagr != null)
            mInfiniteViewpagr.startAutoScroll();
    }

    @Override
    public void onStop()
    {
        if (mInfiniteViewpagr != null)
            mInfiniteViewpagr.stopAutoScroll();
        super.onStop();
    }
}
